﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace MLRobotic.Tower.Common
{
    public static class ExtensionMethods
    {
        public static ushort ToUShort(this bool[] tb)
        {
            ushort value = 0;

            for (int i = 0; i < tb.Length; i++)
            {
                if (tb[i])
                    value += (ushort)Convert.ToInt16(Math.Pow(2, i));
            }

            return value;
        }

        public static string ToBoolString(this bool[] tb)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < tb.Length; i++)
                sb.Append(tb[i] ? "1 " : "0 ");

            return sb.ToString().TrimEnd();
        }
    }
}
